package com.wqtz.chechai.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.orhanobut.logger.Logger;
import com.wqtz.chechai.R;
import com.wqtz.chechai.base.rebaseadapter.MyHolder;
import com.wqtz.chechai.base.rebaseadapter.RecyclerAdapter;
import com.wqtz.chechai.bean.SeriesBean;

import java.util.List;

/**
 * 项目名称： CheChai
 * 创建人 : Liberation
 * 创建时间: 2016/12/28 15:06
 */

public class CarSeriesAdapter extends RecyclerAdapter<SeriesBean.ResultBean.PinpaiListBean> {

   Context mContext;

	public CarSeriesAdapter(int rsId, List<SeriesBean.ResultBean.PinpaiListBean> data,Context context) {
		super(rsId, data);
		mContext =context ;
	}

	@Override
	public int itemType(int position) {
		return 0;
	}

	@Override
	public void onBindMyViewHolder(MyHolder holder, int position, final List<SeriesBean.ResultBean.PinpaiListBean> data) {
		final SeriesBean.ResultBean.PinpaiListBean entity= data.get(position);
		if(entity!=null){
			holder.setText(R.id.title,entity.getPpname());
			mClick.outClick(entity.getPpname(),data); //大标题的车型
			CarSeriesSecondAdapter adapter = new CarSeriesSecondAdapter(R.layout.item_carseris_second);
			adapter.addData(data.get(position).getXilie());
			((ListView)(holder.getView(R.id.lv))).setAdapter(adapter);
			adapter.setSecondClick(new CarSeriesSecondAdapter.secondOnClickCallBack() {
				@Override
				public void secondClick(int position, List<SeriesBean.ResultBean.PinpaiListBean.XilieBean> list) {
					mClick.bigClick(position,list);
				}
			});
		}

	}

	private BigOnClick mClick;
	public void setBigClick(BigOnClick click){
		mClick=click;
	}
	public interface BigOnClick{
		void bigClick(int positon,List<SeriesBean.ResultBean.PinpaiListBean.XilieBean> list);
		void outClick(String carSeriesName,List<SeriesBean.ResultBean.PinpaiListBean> data);
	}
}
